﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using House.DAL;
using Host.Modle;
namespace House
{
    public class SystemDAL:House.IDAL.ISystemDAL 
    {


        //#region 部门管理
        ///// <summary>
        ///// 获取部门表数据
        ///// </summary>
        ///// <returns></returns>
        //public List<Branch> bumen()
        //{
        //    List<Host.Branch> list = new List<Host.Branch>();
        //    string sql = "select * from Branch";
        //    DataTable dt = DBhelper.GetTable(sql);
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        Host.Branch b = new Host.Branch();
        //        b.Bmid = Convert.ToInt32(dt.Rows[i]["Bmid"]);
        //        b.Bmname = dt.Rows[i]["Bmname"].ToString();
        //        b.Remark = dt.Rows[i]["Remark"].ToString();
        //        b.Status = Convert.ToInt32(dt.Rows[i]["Status"]);
        //        list.Add(b);
        //    }
        //    return list;
        //}
        ///// <summary>
        ///// 部门添加
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int bmadd(Host.Modle.Branch b)
        //{
        //    string sql = string.Format("insert into Branch values('{0}',{1},'{2}')", b.Bmname, b.Status, b.Remark);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 删除部门
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public int bmdel(int id)
        //{
        //    string sql = string.Format("delete from Branch where Bmid={0}", id);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 部门修改
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int bmupd(Host.Modle.Branch b)
        //{
        //    string sql = string.Format("update Branch set Bmname='{0}',Status={1},Remark='{2}' where Bmid={3}", b.Bmname, b.Status, b.Remark, b.Bmid);
        //    return DBhelper.NonQuery(sql);
        //}
        //#endregion

        //#region 角色管理
        ///// <summary>
        ///// 获取角色表数据
        ///// </summary>
        ///// <returns></returns>
        //public List<Host.Role> js()
        //{
        //    List<Host.Role> list = new List<Host.Role>();
        //    string sql = "select * from Role";
        //    DataTable dt = DBhelper.GetTable(sql);
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        Host.Role r = new Host.Role();
        //        r.JsID = Convert.ToInt32(dt.Rows[i]["JsID"]);
        //        r.JsName = dt.Rows[i]["JsName"].ToString();
        //        r.JsStatus = Convert.ToInt32(dt.Rows[i]["JsStatus"]);
        //        r.Remarks = dt.Rows[i]["Remarks"].ToString();
        //        list.Add(r);
        //    }
        //    return list;
        //}
        ///// <summary>
        ///// 角色添加
        ///// </summary>
        ///// <param name="r"></param>
        ///// <returns></returns>
        //public int jsadd(Host.Role r)
        //{
        //    string sql = string.Format("insert into Role values('{0}',{1},'{2}')", r.JsName, r.JsStatus, r.Remarks);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 删除角色
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public int jsdel(int id)
        //{
        //    string sql = string.Format("delete from Role where JsID={0}", id);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 角色修改
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int jsupd(Host.Role r)
        //{
        //    string sql = string.Format("update Role set JsName='{0}',JsStatus={1},Remarks='{2}' where JsID={3}", r.JsName, r.JsStatus, r.Remarks, r.JsID);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 获取权限表数据
        ///// </summary>
        ///// <returns></returns>
        //public List<Host.Power> power()
        //{
        //    List<Host.Power> list = new List<Host.Power>();
        //    string sql = "select * from Power";
        //    DataTable dt = DBhelper.GetTable(sql);
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        Host.Power p = new Host.Power();
        //        p.DivisionID = Convert.ToInt32(dt.Rows[i]["DivisionID"]);
        //        p.PowerID = Convert.ToInt32(dt.Rows[i]["PowerID"]);
        //        p.PowerName = dt.Rows[i]["PowerName"].ToString();
        //        p.PowerUrl = dt.Rows[i]["PowerUrl"].ToString();
        //        list.Add(p);
        //    }
        //    return list;
        //}
        ///// <summary>
        ///// 批量分配权限
        ///// </summary>
        ///// <param name="arr"></param>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public int qxadd(string[] arr, int id)
        //{
        //    StringBuilder str = new StringBuilder();
        //    foreach (var item in arr)
        //    {
        //        str.Append(string.Format("insert into RolePower values({0},{1})", id, item));

        //    }
        //    return DBhelper.NonQuery(str.ToString());
        //}
        //#endregion

        //#region 员工管理
        ///// <summary>
        ///// 获取员工表数据
        ///// </summary>
        ///// <returns></returns>
        //public List<Host.Staff> staff()
        //{
        //    List<Host.Staff> list = new List<Host.Staff>();
        //    string sql = "select * from Staff";
        //    DataTable dt = DBhelper.GetTable(sql);
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        Host.Staff s = new Host.Staff();
        //        s.Account = dt.Rows[i]["Account"].ToString();
        //        s.addtime = Convert.ToDateTime(dt.Rows[i]["Status"]);
        //        s.CardID = dt.Rows[i]["CardID"].ToString();
        //        s.Email = dt.Rows[i]["Email"].ToString();
        //        s.Pwd = dt.Rows[i]["Pwd"].ToString();
        //        s.Rest = Convert.ToInt32(dt.Rows[i]["Rest"]);
        //        s.RoleID = Convert.ToInt32(dt.Rows[i]["RoleID"]);
        //        s.Sex = dt.Rows[i]["Sex"].ToString();
        //        s.Staffbm = Convert.ToInt32(dt.Rows[i]["Staffbm"]);
        //        s.StaffID = Convert.ToInt64(dt.Rows[i]["Staffbm"]);
        //        s.Staffname = dt.Rows[i]["Staffname"].ToString();
        //        s.StaffTel = dt.Rows[i]["StaffTel"].ToString();
        //        list.Add(s);
        //    }
        //    return list;
        //}
        ///// <summary>
        ///// 员工添加
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int staffadd(Host.Staff s)
        //{
        //    string sql = string.Format("insert into Staff values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7},{8},{9},{10})", s.Staffname, s.CardID, s.Sex, s.StaffTel, s.Email, s.Account, s.Pwd, s.Staffbm, s.RoleID, s.Rest, s.addtime);

        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 删除员工
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public int staffdel(int id)
        //{
        //    string sql = string.Format("delete from staff where StaffID={0}", id);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 修改员工信息
        ///// </summary>
        ///// <param name="s"></param>
        ///// <returns></returns>
        //public int staffupd(Host.Staff s)
        //{
        //    string sql = string.Format("update staff set Staffname='{0}',CardID='{1}',Sex='{2}',StaffTel='{3}',Email='{4}',Account='{5}',Pwd='{6}',Staffbm={7},RoleID={8},Rest={9},addtime={10} where StaffID={11}", s.Staffname, s.CardID, s.Sex, s.StaffTel, s.Email, s.Account, s.Pwd, s.Staffbm, s.RoleID, s.Rest, s.addtime);
        //    return DBhelper.NonQuery(sql);
        //}

        //#endregion

        //#region 权限管理
        ///// <summary>
        ///// 权限添加
        ///// </summary>
        ///// <param name="p"></param>
        ///// <returns></returns>
        //public int qxadd(Host.Power p)
        //{
        //    string sql = string.Format("insert into Power values ('{0}','{1}',{2})", p.PowerName, p.PowerUrl, p.DivisionID);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 删除权限
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public int qxdel(int id)
        //{
        //    string sql = string.Format("delete from Power where PowerID={0}", id);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 权限修改
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int qxupd(Host.Power p)
        //{
        //    string sql = string.Format("update Power set PowerName='{0}',PowerUrl='{1}',DivisionID={2} where PowerID=[3}", p.PowerName, p.PowerUrl, p.DivisionID, p.PowerID);
        //    return DBhelper.NonQuery(sql);
        //}
        //#endregion

        //#region 字典管理
        //  /// <summary>
        ///// 获取字典表数据
        ///// </summary>
        ///// <returns></returns>
        //public List<Host.Wordbook> word()
        //{
        //    List<Host.Wordbook> list = new List<Host.Wordbook>();
        //    string sql = "select * from Wordbook";
        //    DataTable dt = DBhelper.GetTable(sql);
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        Host.Wordbook w = new Host.Wordbook();
        //        w.WorkID = Convert.ToInt32(dt.Rows[i]["WorkID"]);
        //        w.WorkName = dt.Rows[i]["WorkName"].ToString();
        //        w.WorkType = dt.Rows[i]["WorkType"].ToString();
        //        list.Add(w);
        //    }
        //    return list;
        //}
        ///// <summary>
        ///// 字典添加
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int wordadd(Host.Wordbook w)
        //{
        //    string sql = string.Format("insert into Wordbook values ('{0}','{1}')",w.WorkName,w.WorkType);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 字典数据删除
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public int worddel(int id)
        //{
        //    string sql = string.Format("delete from Wordbook where WorkID={0}", id);
        //    return DBhelper.NonQuery(sql);
        //}
        ///// <summary>
        ///// 字典数据修改
        ///// </summary>
        ///// <param name="b"></param>
        ///// <returns></returns>
        //public int wordupd(Host.Wordbook w)
        //{
        //    string sql = string.Format("update Wordbook set WorkName='{0}',WorkType='{1}' where WorkID={2}",w.WorkName,w.WorkType,w.WorkID);
        //    return DBhelper.NonQuery(sql);
        //}
        //#endregion


        public List<T> SelectEntity<T>()
        {
            return Common.SelectEntity<T>();
        }
    }
}
